<?php
    require_once("lib/includes.php");

    $action = new Action();

    echo json_encode(
        $action->Invoke(function(JSONReply $reply)
        {
            $gameId = (int)$_POST['gameid'];
            $objectId = (int)$_POST['objectid'];

            DB::Connect();

            Queries::UpdateObjectsQuestions($gameId, (int)1, "GuessedObject");

            Queries::SetPlayedObject($gameId, $objectId);

            Queries::SetGuessedRank($gameId, (int)1);

            Queries::IncrementGuessesForObject($objectId);

            // return the expected answers to the questions asked for the (correctly) guessed object
            $expectedAnswers = Queries::GetExpectedAnswersForGame($gameId, $objectId);

            $reply->SetData($expectedAnswers);

            DB::Disconnect();
        }));
